/**
 * 
 */
package com.dsbridge.bank.business;

import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.dsbridge.bank.dao.CustomerDAO;
import com.dsbridge.bank.model.Customer;

/**
 * @author Naveen
 * 
 */
@Service
public class CustomerBusinessService implements
		CustomerBusinessServiceInterface {
	@Autowired
	private CustomerDAO cdao;

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.dsbridge.bank.business.CustomerBusinessInterface#insert(com.dsbridge
	 * .bank.model.Customer)
	 */
	@Override
	@Transactional(propagation = Propagation.REQUIRED)
	public Customer insert(Customer c) throws Exception {

		int i = cdao.insert(c);
		c.setCustomerid(i);

		return c;

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.dsbridge.bank.business.CustomerBusinessInterface#update(com.dsbridge
	 * .bank.model.Customer)
	 */
	@Override
	@Transactional(propagation = Propagation.REQUIRED)
	public Customer update(Customer c) throws SQLException {

		int j = cdao.update(c);
		return c;

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.dsbridge.bank.business.CustomerBusinessInterface#delete(com.dsbridge
	 * .bank.model.Customer)
	 */
	@Override
	@Transactional(propagation = Propagation.REQUIRED)
	public Customer delete(Customer c) throws SQLException {

		Customer c1 = cdao.delete(c);
		return c1;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.dsbridge.bank.business.CustomerBusinessInterface#retrieveCustomerbyTaxid
	 * (java.lang.String)
	 */
	@Override
	@Transactional(propagation = Propagation.REQUIRED)
	public Customer retrieveCustomerbyTaxid(int taxid) throws SQLException {

		System.out.println(taxid + "in retrive method business service");
		Customer l = cdao.retrieveCustomerbyTaxid(taxid);
		return l;

	}

	public List<Customer> showAllCustomer() {

		return cdao.showAllCustomer();
	}

}
